package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type Config struct {
	MySQLConfig
	RedisConfig
}

type MySQLConfig struct {
	User     string
	Password string
	Host     string
	Port     int
	Database string
}
type RedisConfig struct {
	Host     string
	Password string
}

var AppConfig Config

func Init() {
	viper.SetConfigFile("./appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("配置文件读取失败")
	}
	err = viper.Unmarshal(&AppConfig)
	if err != nil {
		fmt.Println("配置文件解析失败")
	}
	fmt.Println(AppConfig)
}
